package cn.stylefeng.guns.modular.contactus.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.contactus.entity.ContactUs;
import cn.stylefeng.guns.modular.contactus.model.params.ContactUsParam;
import cn.stylefeng.guns.modular.contactus.service.ContactUsService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 * 联系我们控制器
 *
 * @author liuqiang
 * @Date 2020-02-12 20:57:06
 */
@RestController
@RequestMapping("/contactUs")
public class ContactUsController extends BaseController {

    @Autowired
    private ContactUsService contactUsService;

    /**
     * 新增接口
     *
     * @author liuqiang
     * @Date 2020-02-12
     */
    @PostMapping("/addItem")
    public ResponseData addItem(@RequestBody ContactUsParam contactUsParam) {
        contactUsParam.setId(1);
        this.contactUsService.add(contactUsParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author liuqiang
     * @Date 2020-02-12
     */
    @PostMapping("/editItem")
    public ResponseData editItem(@RequestBody ContactUsParam contactUsParam) {
        contactUsParam.setId(1);
        this.contactUsService.update(contactUsParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author liuqiang
     * @Date 2020-02-12
     */
    @RequestMapping("/delete")
    public ResponseData delete(ContactUsParam contactUsParam) {
        this.contactUsService.delete(contactUsParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author liuqiang
     * @Date 2020-02-12
     */
    @GetMapping("/detail")
    public ResponseData detail(ContactUsParam contactUsParam) {
        contactUsParam.setId(1);
        ContactUs detail = this.contactUsService.getById(contactUsParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author liuqiang
     * @Date 2020-02-12
     */
    @GetMapping("/list")
    public LayuiPageInfo list(ContactUsParam contactUsParam) {
        return this.contactUsService.findPageBySpec(contactUsParam);
    }

}


